﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;

namespace Hired
{
    public static class Encryption
    {
        public static string md5Encrypt(string input)
        {
            MD5 m = MD5.Create();
            StringBuilder sb = new StringBuilder();
            byte[] hashPW = Encoding.Default.GetBytes(input);

            hashPW = m.ComputeHash(hashPW);
            
            foreach (byte b in hashPW)
            {
                sb.Append(b.ToString("x2"));
            }

            string password = sb.ToString();

            return password;
        }

        public static bool verify(string input, string encrypted)
        {
            bool check = false;

            if (encrypted == md5Encrypt(input))
            {
                check = true;
            }
            else
            {
                check = false;
            }
            return check;
        }
    }
}
